/*
 * @Author: LiZhiWei
 * @Date: 2025-07-14 08:58:30
 * @LastEditors: wjc
 * @LastEditTime: 2025-10-27 17:40:09
 * @Description:
 */
import defaultSettings from '#/utils/settings'

const tokenName = defaultSettings.cookieTokenName

export function getToken(): string {
  // return Cookies.get(tokenName)
  return localStorage.getItem(tokenName) || ''
}

export function setToken(token: string) {
  // return Cookies.set(tokenName, token)
  return localStorage.setItem(tokenName, token)
}

export function removeToken() {
  // return Cookies.remove(tokenName)
  return localStorage.removeItem(tokenName)
}

export function getActions(pre: string, reset?: AclPermission): AclPermission {
  return {
    show: reset?.show ?? `${pre}-show`,
    add: reset?.add ?? `${pre}-store`,
    edit: reset?.edit ?? `${pre}-update`,
    del: reset?.del ?? `${pre}-destroy-batch`,
    delBatch: reset?.delBatch ?? `${pre}-destroy-batch`,
    trashed: reset?.trashed ?? `${pre}-trashed`,
  }
}

export function getTrashedActions(pre: string, reset?: AclPermission): AclPermission {
  return {
    index: reset?.index ?? `${pre}-index`,
    forceDel: reset?.forceDel ?? `${pre}-force-destroy`,
    restore: reset?.restore ?? `whitelist`,
  }
}
